import React from 'react';
import TweenOne from 'rc-tween-one';
import OverPack from 'rc-scroll-anim/lib/ScrollOverPack';
import { isImg } from './utils';

class Footer2 extends React.PureComponent {
  render() {
    const { ...props } = this.props;
    delete props.dataSource;
    delete props.isMobile;
    
    // 硬编码的数据
    const linksData = {
      className: 'links',
      children: [
        {
          name: 'weibo',
          href: '#',
          className: 'links-weibo',
          children:
            ''
        },
        {
          name: 'zhihu',
          href: '#',
          className: 'links-zhihu',
          children:
            '',
        },
      ],
    };
    
    const copyrightData = {
      className: 'copyright',
      children: [
        {
          name: 'image',
          children: '/images/NuuAwJBxewWglRSoNjET.png',
          className: 'copyright-logo',
        },
        {
          name: 'group',
          children: '蚂蚁金服体验科技大会',
          className: 'copyright-group',
        },
        {
          name: 'image2',
          children: '/images/fgGmQUfiUfSBfvsQpfOj.svg',
          className: 'copyright-line',
        },
        {
          name: 'copyright',
          children: 'Copyright © 蚂蚁金融服务集团',
          className: 'copyright-text',
        },
      ],
    };

    return (
      <div 
        {...props} 
        className="home-page-wrapper footer2-wrapper"
      >
        <OverPack 
          className="home-page footer2" 
          playScale={0.05}
        >
          <TweenOne {...linksData}>
            {linksData.children.map((item, i) => {
              return (
                <a key={i.toString()} {...item}>
                  <img src={item.children} height="100%" alt="img" />
                </a>
              );
            })}
          </TweenOne>
          <TweenOne
            animation={{ x: '+=30', opacity: 0, type: 'from' }}
            key="copyright"
            {...copyrightData}
          >
            {copyrightData.children.map((item, i) =>
              React.createElement(
                item.name.indexOf('title') === 0 ? 'h1' : 'div',
                { key: i.toString(), ...item },
                typeof item.children === 'string' && item.children.match(isImg)
                  ? React.createElement('img', {
                      src: item.children,
                      alt: 'img',
                    })
                  : item.children
              )
            )}
          </TweenOne>
        </OverPack>
      </div>
    );
  }
}

export default Footer2;
